<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('班级列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <input type="hidden" name="teacherId" id="teacherId" th:value="${teacherId}"/>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="addClazz()" >
                <i class="fa fa-plus"></i> 添加
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>

    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "mgr/teacher";

        $(function() {
            var options = {
                url: prefix + "/clazzList",
                modalName: "班级",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'clazzId', 
                    title : '班级id',
                    visible: false
                },
                {
                    field : 'clazzName', 
                    title : '班级名称'
                },
                    {
                        field: 'createTime',
                        title: '创建时间',
                        sortable: true
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="delClazz(\'' + row.clazzId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function delClazz(clazzId) {
            var teacherId = $('#teacherId').val();
            var url = prefix + '/delClazz/' + clazzId + '/' + teacherId;
            $.operate.get(url);
        }
        function addClazz() {
            var teacherId = $('#teacherId').val();
            var url = prefix + '/add/' + teacherId;
            $.modal.open("添加班级", url);
        }
    </script>
</body>
</html>